package com.lcy.controller;


import com.github.pagehelper.PageInfo;
import com.lcy.entity.User;
import com.lcy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("user")

    public String show(Model model,
                       @RequestParam(value = "page",required = false,defaultValue = "1") Integer page,
                       @RequestParam(value = "pageSize",required = false,defaultValue = "5")Integer pageSize,
                       User user){
        model.addAttribute("pageInfo",userService.selUserBy(user,page,pageSize));
        model.addAttribute("user",user);
        return "list";
    }
    @RequestMapping("userandolder")

    public String userandolder(Model model,
                       @RequestParam(value = "page",required = false,defaultValue = "1") Integer page,
                       @RequestParam(value = "pageSize",required = false,defaultValue = "5")Integer pageSize,
                       User user){
        PageInfo pageInfo = userService.selAllUserAndOrder(user,page, pageSize);
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("user",user);
        return "newlist";
    }
}
